﻿@model DHQGHN.PM2.Models.Online.ChetMatTichModel

<script>
    @functions{
        public string GetAntiForgeryToken()
        {
            string cookieToken, formToken;
            AntiForgery.GetTokens(null, out cookieToken, out formToken);
            return cookieToken + "," + formToken;
        }
    };
    jQuery(function ($) {
        Tooltip();
        Checkngay("DAYDEATH");
        Checkthang("MONTHDEATH");
        Checknam("YEARDEATH");
        Checkngay("DAYMISSING");
        Checkthang("MONTHMISSING");
        Checknam("YEARMISSING");
        $("#divLoading").show();
        $("#btnNext").attr("disabled", "disabled");
        $("#btnBack").attr("disabled", "disabled");
        $.ajax({
            url: '@Url.Action("GetAllByListName")',
            dataType: 'json',
            headers: {
                'VerificationToken': '@GetAntiForgeryToken()'
            },
            method: 'GET',
            data: { 'tablename': 'DEATH_CAUSE' },
            success: function (data, textStatus, jqXHR) {
                $(".DEATH_CAUSE_ID").append('<option value="">' +
      '-- Chọn Nguyên nhân --' + '</option>');
                $.each(data, function (i, item) {
                    $(".DEATH_CAUSE_ID").append('<option value="' + item.CodeID + '">' +
                         item.Name + '</option>');
                });
                $(".DEATH_CAUSE_ID").val("@Model.DEATH_CAUSE_ID");
            },
            complete: function (jqXHR, textStatus) {
                $("#divLoading").hide();
                $("#btnNext").removeAttr("disabled");
                $("#btnBack").removeAttr("disabled");
            },

        });

    });


    function ClickButton(Next) {
        var ngayde = $("#DAYDEATH").val();
        var thangde = $("#MONTHDEATH").val();
        var namde = $("#YEARDEATH").val();
        var ngaymi = $("#DAYMISSING").val();
        var thangmi = $("#MONTHMISSING").val();
        var nammi = $("#YEARMISSING").val();
        var tmp = $('#row' + $("#RESIDENT_ID").val());
        var rownext = tmp.next();
        var residentNextId = rownext.attr("resident_id");
        if (residentNextId == null || residentNextId.length <= 0) {
            residentNextId = "-1";
        }

        var dataSend = {
            'HOUSEHOLD_ID': $("#HOUSEHOLD_ID").val(),
            'RESIDENT_ID': $("#RESIDENT_ID").val(),
            'DEATH_DATE': namde + thangde + ngayde,
            'DEATH_CAUSE_ID': $(".DEATH_CAUSE_ID").val(),
            'MISSING_DATE': nammi + thangmi + ngaymi,
            'ResidentNextId': residentNextId,
            'NEXT': Next,

        };
        var jqXHR = $.ajax({
            url: '@Url.Action("ChatMattich","Online")',
            dataType: 'html',
            headers: {
                'VerificationToken': '@GetAntiForgeryToken()'
            },
            method: 'post',
            cache: false,
            data: dataSend,
            success: function myfunctionSuccess(data, textStatus, jqXHR) {
                if (Next == "2") {
                    $('#formLogin').html(data);
                }
                else {
                    $('#loadPartial').empty();
                    $('#loadPartial').html(data);

                }
            },
            complete: function (jqXHR, textStatus) {
                $("#divLoading").hide();
                $("#btnNext").removeAttr("disabled");
                $("#btnBack").removeAttr("disabled");
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert('Có lỗi xảy ra trong quá trình lưu thông tin: ' + errorThrown);
            },

        });
    }
    $("#btnNext").click(function (event, giatri) {
        if (checkhtml()) {
            alert("Dữ liệu nhập không được có ký tự '<' ở đầu.");
        } else {
            if (giatri != null) {
                ClickButton(giatri);
            }
            else {
                if (Checkdatetime("DAYDEATH", "MONTHDEATH", "YEARDEATH") == 0 && Checkdatetime("DAYMISSING", "MONTHMISSING", "YEARMISSING") == 0) {
                    ClickButton(1);
                }
            }
        }
    });
    $("#btnBack").click(function () {
        if (checkhtml()) {
            alert("Dữ liệu nhập không được có ký tự '<' ở đầu.");
        } else {
            ClickButton(0);
        }
    });
</script>
<style>
    .ui-tooltip, .arrow:after {
        background: #FAFAD2;
    }

    .ui-tooltip {
        color: black;
        font-size: 12px;
    }

    .arrow {
        width: 70px;
        height: 16px;
        overflow: hidden;
        position: absolute;
        left: 50%;
        margin-left: -35px;
        bottom: -16px;
    }

        .arrow.top {
            top: -16px;
            bottom: auto;
        }

        .arrow.left {
            left: 20%;
        }

        .arrow:after {
            content: "";
            position: absolute;
            left: 20px;
            top: -20px;
            width: 25px;
            height: 25px;
            box-shadow: 6px 5px 9px -9px black;
            -webkit-transform: rotate(45deg);
            -ms-transform: rotate(45deg);
            transform: rotate(45deg);
        }

        .arrow.top:after {
            bottom: -20px;
            top: auto;
        }
</style>
<div class="noidung-nhaponline">
    <div class="login-fields2">
        <p style="float: left; padding-right: 5px; vertical-align: top;">
            <img src="../Images/rt_arrow.gif">
        <p>Thông tin về Chết/Mất tích:</p>
    </div>
    <div class="row row-online-table">
        <div class="col-md-3 lbl-online1">
            @Html.LabelFor(m => m.DEATH_DATE, new { @class = "control-lable" })
        </div>
        <div class="col-md-5">
            @Html.TextBoxFor(model => model.DAYDEATH, new { @class = "form-control", style = "width: 20%; display: inline;", MaxLength = 2, @title = @Html.ToolTipMessageFor(m => m.DAYDEATH) })/@Html.TextBoxFor(model => model.MONTHDEATH, new { @class = "form-control", style = "width: 20%; display: inline;", MaxLength = 2, @title = @Html.ToolTipMessageFor(m => m.MONTHDEATH) })/@Html.TextBoxFor(model => model.YEARDEATH, new { @class = "form-control", style = "width: 40%; display: inline;", MaxLength = 4, @title = @Html.ToolTipMessageFor(m => m.YEARDEATH) })
        </div>
    </div>

    <div class="row row-online-table">
        <div class="col-md-3 lbl-online1">
            @Html.LabelFor(m => m.DEATH_CAUSE_ID, new { @class = "control-lable" })
        </div>
        <div class="col-md-4">
            <select class="DEATH_CAUSE_ID form-control "></select>
        </div>
    </div>
    <div class="row row-online-table">
        <div class="col-md-3 lbl-online1">
            @Html.LabelFor(m => m.MISSING_DATE, new { @class = "control-lable" })
        </div>
        <div class="col-md-5">
            @Html.TextBoxFor(model => model.DAYMISSING, new { @class = "form-control", style = "width: 20%; display: inline;", MaxLength = 2, @title = @Html.ToolTipMessageFor(m => m.DAYMISSING) })/@Html.TextBoxFor(model => model.MONTHMISSING, new { @class = "form-control", style = "width: 20%; display: inline;", MaxLength = 2, @title = @Html.ToolTipMessageFor(m => m.MONTHMISSING) })/@Html.TextBoxFor(model => model.YEARMISSING, new { @class = "form-control", style = "width: 40%; display: inline;", MaxLength = 4, @title = @Html.ToolTipMessageFor(m => m.YEARMISSING) })
        </div>
    </div>
    <div>
        @Html.HiddenFor(model => model.RESIDENT_ID)
        @Html.HiddenFor(model => model.HOUSEHOLD_ID)
    </div>
    <center>
        <input type="button" class="btn btn-small btn-small_online btn-success buttonClick " id="btnBack" value="<< Quay lại">
        <input type="button" class="btn btn-small btn-small_online btn-success buttonClick" id="btnNext" value="Tiếp tục >>">
    </center>
</div>

